﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Configuration;
using IBLL;

namespace BLLFactory
{
    public class DataAccess
    {

        private static readonly string path = ConfigurationManager.AppSettings["WebBLL"];

        private DataAccess()
        {
        }

        //添加其他表的Factory请在这里添加

        public static IBLL.IMessagesInVideoDisplay CreateMessagesInVideoDisplay()
        {
            //获得Message的DAL类（在我们的项目里，path指向DAL这个工程）
            string className = path + ".MessagesInVideoDisplay";

            return (IBLL.IMessagesInVideoDisplay)Assembly.Load(path).CreateInstance(className);
        }

        public static IBLL.IUserInfoInAdmin GetUserInfo()
        {
            //获得Message的DAL类（在我们的项目里，path指向DAL这个工程）
            string className = path + ".UserInfoInAdmin";

            return (IBLL.IUserInfoInAdmin)Assembly.Load(path).CreateInstance(className);
        }

        public static IBLL.IAdminInAdmin GetAdmin()
        {
            //获得Message的DAL类（在我们的项目里，path指向DAL这个工程）
            string className = path + ".AdminInAdmin";

            return (IBLL.IAdminInAdmin)Assembly.Load(path).CreateInstance(className);
        }

        public static IBLL.IVideoInAdmin GetVideoInfo()
        {
            //获得Message的DAL类（在我们的项目里，path指向DAL这个工程）
            string className = path + ".VideoInAdmin";

            return (IBLL.IVideoInAdmin)Assembly.Load(path).CreateInstance(className);
        }

        public static IBLL.IUserInfoEdit GetUser()
        {
            //获得Message的DAL类（在我们的项目里，path指向DAL这个工程）
            string className = path + ".UserInfoEdit";

            return (IBLL.IUserInfoEdit)Assembly.Load(path).CreateInstance(className);

        }

        public static UserinfoIBLL getUserinfoIBLL()
        {
            string className = path + ".UserinfoBLL";
            //利用反射技术，动态加载指定类型
            return (UserinfoIBLL)Assembly.Load(path).CreateInstance(className);
        }

        public static IAlbum GetAlbum()
        {
            string className = path + ".Album";
            //利用反射技术，动态加载指定类型
            return (IAlbum)Assembly.Load(path).CreateInstance(className);
        }

        public static IVideo GetVideo()
        {
            string className = path + ".Video";
            //利用反射技术，动态加载指定类型
            return (IVideo)Assembly.Load(path).CreateInstance(className);
        }

        public static IVideoInVideoPage GetVideoInVideoPage()
        {
            string className = path + ".VideoInVideoPage";
            return (IVideoInVideoPage)Assembly.Load(path).CreateInstance(className);
        }

        public static PictureIBLL getPictureIBLL()
        {
            string className = path + ".PictureBLL";
            //利用反射技术，动态加载指定类型
            return (PictureIBLL)Assembly.Load(path).CreateInstance(className);
        }

        public static IAnnounceBLL getAnnouncIBLL()
        {
            string className = path + ".AnnounceBLL";
            //利用反射技术，动态加载指定类型
            return (IAnnounceBLL)Assembly.Load(path).CreateInstance(className);
        }

        public static IMessage getMessage()
        {
            string className = path + ".Message";
            //利用反射技术，动态加载指定类型
            return (IMessage)Assembly.Load(path).CreateInstance(className);
        }

    }
}
